package class2;

/**
 * https://leetcode.cn/problems/a-number-after-a-double-reversal/
 * 反转两次的数字
 */
public class Code12_isSameAfterReversals {
    public static void main(String[] args) {
        int num = 12300;
        boolean res = isSameAfterReversals1(num);
        System.out.println("res = " + res);

        boolean sameAfterReversals2 = isSameAfterReversals2(num);
        System.out.println("sameAfterReversals2 = " + sameAfterReversals2);


    }

    public static boolean isSameAfterReversals1(int num) {
        return reverse(reverse(num)) == num;
    }

    public static int reverse(int num) {
        int ans = 0;
        while (num != 0) {
            ans *= 10;
            ans += num % 10;
            num /= 10;
        }
        return ans;
    }

    public static boolean isSameAfterReversals2(int num) {
        return (num > 0 && num % 10 == 0) ? false : true;

    }


}
